package com.skyolder.crutch.word;

import java.util.LinkedList;

import com.skyolder.crutch.error.GrammarError;
import com.skyolder.crutch.word.token.Token;

public class BufferTokenPiper {
	FilterTokenPiper filterTokenPiper;
	private LinkedList<Token> list=new LinkedList<Token>();
	public BufferTokenPiper(FilterTokenPiper filterTokenPiper){
		this.filterTokenPiper=filterTokenPiper;
	}
	public Token nextToken() throws GrammarError {
		if(list.size()>0){
			Token token=list.removeFirst();
			return token;
		}
		return filterTokenPiper.nextToken();
	}
	public Token peekToken()throws GrammarError{
		Token t=filterTokenPiper.nextToken();
		list.addLast(t);
		return t;
	}
}
